<?php
// 增加广告单
class AddAction extends Action {
	public function index() {
		$this->display ();
	}
	public function doUploadImg() {
		$data ['attachId'] = intval($_POST ['attachId']);
		$data ['attachName'] = t($_POST ['attachName']);
		$data ['cTime'] = time ();
		$data ['uid'] = $this->mid;
		
		$adId = M ( 'ad' )->add ( $data );
		if (! $adId) {
			$this->error ( '系统出问题了，请稍后重试！！！' );
		}
		
		redirect ( SITE_URL . '/add/addInfo/id/' . $adId );
	}
	public function addInfo() {
		$this->assign ( 'id', intval ( $_GET ['id'] ) );
		
		$this->display ('addInfo');
	}
	public function doAddInfo() {
		$map ['id'] = intval ( $_POST ['id'] );
		
		$save ['content'] = t ( $_POST ['content'] );
		
		$res = M ( 'ad' )->where ( $map )->save ( $save );
		if (! $res) {
			$this->error ( '系统出问题了，请稍后重试！！！' );
		}
		
		redirect ( SITE_URL . '/add/addUserInfo/id/' . $map ['id'] );
	}
	public function addUserInfo(){
		$this->assign ( 'id', intval ( $_GET ['id'] ) );
		
		$this->display ('addUserInfo');		
	}
	public function doAddUserInfo() {
		$map ['id'] = intval ( $_POST ['id'] );
	
		$save ['company'] = t ( $_POST ['company'] );
		$save ['linkman_name'] = t ( $_POST ['linkman_name'] );
		$save ['linkman_contact'] = t ( $_POST ['linkman_contact'] );
	
		$res = M ( 'ad' )->where ( $map )->save ( $save );
		if (! $res) {
			$this->error ( '系统出问题了，请稍后重试！！！' );
		}
	
		redirect ( SITE_URL . '/add/share/id/' . $map ['id'] );
	}
	function share(){
		$this->assign ( 'id', intval ( $_GET ['id'] ) );
		
		$this->display ();		
	}
}